package org.opens.converter.mybatisJdbcType.handle;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import org.opens.converter.mybatisJdbcType.I_MybatisJdbcTypeConverter;
import org.opens.converter.mybatisJdbcType.MybatisJdbcTypeConverterEntity;
import org.opens.exception.BusinessException;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能描述
 *
 * @author by zhangyuming
 * @date 2023/3/7
 */
public class OracleMybatisJdbcTypeConverterHandle implements I_MybatisJdbcTypeConverter {

    private static Log log = LogFactory.get(OracleMybatisJdbcTypeConverterHandle.class);

    private static Map<String, MybatisJdbcTypeConverterEntity> converterMap = new HashMap<>();

    static {
        converterMap.put("bit", MybatisJdbcTypeConverterEntity.builder().jdbcTypeName("").build());
    }

    @Override
    public MybatisJdbcTypeConverterEntity dbType2JdbcType(String dbSqlType) {
        MybatisJdbcTypeConverterEntity converterEntity = converterMap.get(dbSqlType);
        if (converterEntity == null) {
            throw new BusinessException("未配置的sqlType类型对应的jdbcType类型: " + dbSqlType + ", 终止生成!");
        }
        return converterMap.get(dbSqlType);
    }

}
